package classes
{
	import flash.geom.Rectangle;
	
	public class Column
	{
		[Bindable]
		public 		var x		: int;
		public 		var stripes	: Array = new Array();		
		protected 	var	adata	: AnalyzedData;


		public function Column(data:AnalyzedData,x:int)
		{
			this.adata = data;
			this.x = x;
		}
		
		
		public function getColumnData():Array{
			var columnMatrix:Matrix = this.adata.matrix.slice(new Rectangle(this.x-1, 0, 3, this.adata.matrix.height));
			var c:Array = new Array();
			for(var y:int=0;y<columnMatrix.height;y++){
				var s:Number = 0;
				for each (var d:Array in columnMatrix.data)
					 s+=d[y];
				c.push(s);
			}
			return c; 
		}
		
		
		public function generateStripes():void{
			var cd:Array = this.getColumnData()
			var mm:Object = Utils.minMax(cd);
			cd = cd.map(function(item:*, idx:int, ar:Array):*{
				return (item-mm.min)/mm.diff;
			});
			cd = cd.map(function(item:*, idx:int, ar:Array):*{
				return (item>0.9)? 1 : item;
			});
			var diff:Array = AnalyzedData.diff(cd,2);
			var strias:Array = AnalyzedData.findZeros( diff,true );
			
			for each(var y:int in strias){
				this.stripes.push(new Stripe(this,y)); 
			} 
		}
		
	}
}